//
//  ViewController.swift
//  myOcrTest
//
//  Created by joke on 16/1/11.
//  Copyright © 2016年 joke. All rights reserved.
//

import UIKit

class ViewController: UIViewController ,UINavigationControllerDelegate,UIImagePickerControllerDelegate{


    @IBAction func takePhoto(sender: UIBarButtonItem) {
        imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = .Camera
        imagePicker.modalPresentationStyle = .OverCurrentContext
        presentViewController(imagePicker, animated: true, completion: nil)
        
    }
    @IBOutlet var imageView: UIImageView!
    
    var imagePicker:UIImagePickerController!
    
    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
        print(info)
    }

    
    func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
        imagePicker.dismissViewControllerAnimated(true, completion: nil)
        
        let imageData:NSData = UIImagePNGRepresentation(image)!
//        print(imageData)
        let myImage:UIImage = UIImage(data: imageData)!
        imageView.image = myImage
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        print(UIDevice.currentDevice().systemVersion )
        if Double(UIDevice.currentDevice().systemVersion) > 8.0 {
            self.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
        }
//        let myScreen:CGRect = UIScreen.mainScreen().applicationFrame
//        print(myScreen)
//        print(imageView.frame)
//        imageView.frame = CGRectMake(0, 0, myScreen.size.width, myScreen.size.height)
//        print(imageView.frame)
//        

        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

